package com.zrrd._0727;

import java.io.*;
/*
   BufferedReader 可以逐行读取数据
   BufferedInputStream 可以读取一大块数据
 */
public class TestBufferedStream {
   public static void main(String[] args) {
      FileInputStream fileInputStream = null;
      InputStream bis = null;
      try {
         File file = new File("yuan.txt");
         fileInputStream = new FileInputStream(file);
         bis = new BufferedInputStream(fileInputStream);
         byte[] bytes = new byte[(int) file.length()];
         try {
            bis.read(bytes);
         } catch (IOException e) {
            throw new RuntimeException(e);
         }
         System.out.println(new String(bytes));
      } catch (FileNotFoundException e) {
         throw new RuntimeException(e);
      } finally {

         if (fileInputStream != null) {
            try {
               fileInputStream.close();
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }

         if (bis != null) {
            try {
               bis.close();
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
      }
   }
}
